import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'   //引入

const routes = [
  {
    //当访问 / 的时候我们会进到layout界面
    path: '/',
    name: 'Layout',//访问到Layout页面
    redirect: "/user",  //重定向，如果访问 / 会自动访问到 /home 中
    // redirect: "/banner",  //一开始转到的页面
    component: Layout,
    //这里使用children进行嵌套路由访问
    children: [
        // 主要管理
      {
        path: 'user',
        name: 'User',
        component: () => import("@/views/User")
      },
        // 轮播图管理
      {
        path: 'banner',
        name: 'Banner',
        component: () => import("@/views/Banner")
      },
        //person页面
      {
        path: '/person',
        name: 'Person',
        component: () => import("@/views/Person")
      },
      {
        path: '/house',
        name: 'House',
        component: () => import("@/views/House")
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import("@/views/Login")
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import("@/views/Register")
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
